{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Objective of this notebook: let me figure out what went wrong with the energy percentage calculating code that ended up putting nearly all the energy in the delta band and no energy anywhere else."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "tau = 2 * np.pi\n",
    "SAMPLE_RATE = 256"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create some synthetic signals to start the debug process\n",
    "def make_signal(freq):\n",
    "    return np.sin(np.linspace(0, 5 * tau * freq, 1280))\n",
    "signal_delta_only = make_signal(2)\n",
    "signal_theta_only = make_signal(5)\n",
    "signal_alpha_only = make_signal(10)\n",
    "signal_beta_only = make_signal(20)\n",
    "signal_logamma_only = make_signal(50)\n",
    "signal_higamma_only = make_signal(100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "def energy_percentages(signal):\n",
    "    \"\"\"\n",
    "    Calculate the percent of energy in various frequency bands. Those bands are:\n",
    "\n",
    "    * Delta (<= 3 Hz)\n",
    "    * Theta (4-7 Hz)\n",
    "    * Alpha (8-13 Hz)\n",
    "    * Beta (14-30 Hz)\n",
    "    * Lower Gamma (30-55 Hz)\n",
    "    * Higher Gamma (65-110 Hz)\n",
    "    \"\"\"\n",
    "    padded = np.array([0] * 100 + list(signal) + [0] * 100)\n",
    "    freqs = np.fft.rfftfreq(len(padded)) * SAMPLE_RATE\n",
    "    fft = np.abs(np.fft.rfft(padded))\n",
    "    overall = np.trapz(fft, freqs)\n",
    "    delta = band_energy(fft, freqs, 0, 3)\n",
    "    theta = band_energy(fft, freqs, 4, 7)\n",
    "    alpha = band_energy(fft, freqs, 8, 13)\n",
    "    beta = band_energy(fft, freqs, 14, 30)\n",
    "    gamma1 = band_energy(fft, freqs, 30, 55)\n",
    "    gamma2 = band_energy(fft, freqs, 65, 110)\n",
    "    return np.array([delta, theta, alpha, beta, gamma1, gamma2]) / overall"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fc56c73a748>]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAGwhJREFUeJzt3XuQXOV55/Hv091zH0mjy0gWMxIjQIvBNpaUMREhjllwMGDHIlVmQ8oVZFa72sqyG7LxbgLx1ibedVVwrSvYVHlxUYAtKMeYxdhStAqBlWFZvAY8AiKQBGi4SYNuI3QbaTSX7n72j/PO0JK6NUeaGfWc49+naqrPefud7qdPT//6nbfPOW3ujoiIpFem2gWIiMjkUtCLiKScgl5EJOUU9CIiKaegFxFJOQW9iEjKKehFRFJOQS8iknIKehGRlMtVuwCAOXPmeEdHR7XLEBFJlE2bNu1399ax+k2JoO/o6KCrq6vaZYiIJIqZvRenn6ZuRERSTkEvIpJyCnoRkZRT0IuIpJyCXkQk5RT0IiIpp6AXEUk5Bf1pvLv/GL/o3l/tMkRExmVKHDA1VV31rWcAePeuz1e3EBGRcdCIXkQk5RT0IiIpp6AXEUm5WEFvZi1m9piZvW5m28zsCjObZWZPmdn2cDkz9DUzu8fMus1ss5ktm9yHICIipxN3RP8d4Al3/yjwSWAbcAew0d0XAxvDOsD1wOLwsxq4d0IrFhGRMzJm0JvZdOB3gAcA3H3I3Q8BK4A1odsa4MawvAJ4yCPPAy1mNn/CKxcRkVjijOgvAHqB75vZy2Z2v5k1AfPcfTdAuJwb+rcBO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Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "padded = np.array([0] * 100 + list(signal_alpha_only) + [0] * 100)\n",
    "freqs = np.fft.rfftfreq(len(padded)) * SAMPLE_RATE\n",
    "fft = np.abs(np.fft.rfft(padded))\n",
    "plt.plot(freqs, fft)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAEoZJREFUeJzt3X+QXXd53/H3BwkRUijUeJtSS0UqVciohMKwKKGkqdOaGblMpFJMkaaZwTM0mgwVpKUkFU1Hw4jOFHCnnrajtAjKhKaAYpzEXZwtavgVghMnWoNiIzsqO7IbbZ0fi2NTGDd2BE//uEdwc31Xe3Z1V7v68n7N7Oj8eO65z3fP3Y/O/e69d1NVSJLa8rT1bkCSNHmGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBm9frjq+99travn37et29JF2V7rnnnq9U1dRydesW7tu3b2dubm697l6SrkpJ/nefOqdlJKlBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ3qFe5J9iQ5m2Q+yeEx+29Ncrr7+l9JHpt8q5KkvpZ9h2qSTcAx4NXAAnAqyUxV3X+xpqr+2VD9W4CXrUGvuopsP/wr691CLw+9+zXr3YK0Jvpcue8G5qvqXFU9CZwA9l2i/gDw0Uk0J0lanT7hfh1wfmh9odv2FEleAOwAPr3E/oNJ5pLMLS4urrRXSVJPfcI9Y7bVErX7gdur6hvjdlbV8aqarqrpqallP9RMkrRKfcJ9Adg2t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CcBr4ReDXu13/CHhTkt9h8HRy9LPpYTBP95+76Y4ngPczeLp1B4PP2rniquoR4K4MXu51yxI1TzL4YXtPN77TDKahYOON6RMMrmjuZXDldPeYmgeAN3Y11wD/aZljvhf4N0nuYjDtsZ5Ge/+PbMxz88vAvcDvAJ8Gfrqq/oDBz8wCg7nh9wG/BXy1qh67Qv1N9FxW1f9j8PuZTyT5PPCHDObQJ35fS+jzeJ8o36GqDam7wrqzql68zq18x0ryrKr6epLnMbiaf1UX/FelofGEwV+X+3JV3brefa2V1ufcJa3enUmeC2wB3nU1B3vnx5O8kcF4vsjgGUmzvHKXpAY1O+cuSd/JDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAb9f3Wl3MjiwhIBAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(6), energy_percentages(signal_alpha_only),\n",
    "        tick_label=['delta', 'theta', 'alpha', 'beta', 'logamma', 'higamma'])\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
